home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / util / hdrunner.sit / Outline Button.c < prev   
Text File  |  1987-04-14  |  2KB  |  66 lines

  1. /*
  2.   * File:        OutlineButton.c -- useritem installer to outline the default button in dialogs.
  3.   * Notes:        Call while the dialog is still invisible.
  4.   */
  5.  
  6. #include    <MacTypes.h>
  7. #include    <DialogMgr.h>
  8.  
  9. /*
  10.   * Outlining is done by installing an user item surrounding the OK button. 
  11.   * The user item procedure then draws the border. This procedure will be called by the
  12.   * Dialog Manager whenever the area containing the OK button needs
  13.   * updating. The simple method of just drawing into the dialog window
  14.   * will fail if any update events are generated -- DrawDialogs() may trash
  15.   * part of the border.
  16.   *
  17.   * CAVEATS:  the useritem must have a higher item number than the button
  18.   *               being highlit.
  19.   */
  20.   
  21.  
  22. /* Forward references */
  23. pascal void        buttonProc();
  24.  
  25. void
  26. OutlineButton(theDialog, defaultID, useritemID)
  27. DialogPtr    theDialog;
  28. int        defaultID;
  29. int        useritemID;
  30. {
  31.     int        itype;
  32.     Handle    cHandle;
  33.     Rect        outlineBox;
  34.     
  35.     /* Get the location of the default button. */
  36.     GetDItem(theDialog, defaultID, &itype, &cHandle, &outlineBox);
  37.  
  38.     /* Set up the useritem to wrap around the OK button and have
  39.        * userProc() as its drawing function.
  40.       */
  41.     InsetRect(&outlineBox, -4, -4);
  42.     SetDItem(theDialog, useritemID, userItem, (Handle) buttonProc, &outlineBox);
  43. }
  44.  
  45. /*
  46.   * buttonProc:    useritem procedure to draw the border around the OK (or other default)
  47.   *            button.
  48.   */
  49.  
  50. static pascal void
  51. buttonProc(theWindow, itemNo)
  52. WindowPtr    theWindow;
  53. int            itemNo;
  54. {
  55.     int        itype;
  56.     Handle    cHandle;
  57.     Rect        outlineBox;
  58.     
  59.     /* Retrieve the outline box. */
  60.     GetDItem((DialogPtr)theWindow, itemNo, &itype, &cHandle, &outlineBox);
  61.  
  62.     PenSize(3,3);
  63.     FrameRoundRect(&outlineBox, 16, 16);
  64.     PenSize(1,1);
  65. }